﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true" CodeBehind="PropertySearch.aspx.cs" Inherits="LizzabethBrownRealEstate.Views.Users.PropertySearch" %>
<%@ Import Namespace="LizzabethBrownRealEstate.Models" %>

<asp:Content ID="Content2" ContentPlaceHolderID="ScriptPlaceHolder" runat="server">
<script type="text/javascript" src="../../Content/javascript/jquery.maskedinput-1.1.3.pack.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
        $("input[type='text']").css("width", "120px");
        $('#fldSearch').dropShadow({ left: 4, top: 15, blur: 8 });

        $("#frmSearch").validate({
            errorClass: "invalid",
            wrapper: "li",
            rules: {
                Bathrooms: { number: true },
                Fireplaces: { number: true },
                FullBaths: { number: true },
                TotalSquareFeet: { number: true },
                TotalLivingArea: { number: true },
                Rooms: { number: true },
                Frontage: { number: true },
                Bedrooms: { number: true }
            },

            errorLabelContainer: "#frmPropertyErr",
            messages: {
                Bathrooms: "Bathrooms requires a valid number.",
                Fireplaces: "Fireplaces requires a valid number.",
                FullBaths: "Full Baths requires a valid number.",
                TotalSquareFeet: "Total Square Feet requires a valid number.",
                TotalLivingArea: "Total Living Area requires a valid number.",
                Rooms: "Room requires a valid number.",
                Frontage: "Frontage requires a valid number.",
                Bedrooms: "Bedrooms requires a valid number."
            }
        });

    });
        
    function selAll(list){
        for (var i=0; i< list.options.length; i++){
            list.options[i].selected = true;
        }
    }
</script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="StylePlaceHolder" runat="server">
    <style type="text/css">
    .invalid {border: dotted 1pt red; }
    </style>
</asp:Content>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContentPlaceHolder" runat="server">
<form id="frmSearch" method="post" enctype="multipart/form-data" action="<%=  Url.Action("DoPropertySearch", "Users" ) %>" >
    <% LBRDataContext dc = new LBRDataContext();  %>
    <div class="contentDiv" style="margin-left:15%">
        <fieldset id="fldSearch" style="width:530px;display:block;">
            <legend>Enter your search criteria...</legend>
            <table>
                <tr class="addPropertyRow">
                    <td class="addPropertyLabel"><label class="label">Location:&nbsp;</label></td>
                    <% object style = new { _class = "locationSelect", ondblclick="selAll(this)" }; %>
                    
                    <td class="addPropertyField"><%= Html.DropDownList("Select...", "LocationList", new SelectList(dc.Locations, "LocationId","Name", ViewData.Model.Location == null ? 0 : ViewData.Model.Location.LocationId), style)%></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr class="addPropertyRow">
                    <td class="addPropertyLabel"><label class="label" for="Bathrooms">#&nbsp;of&nbsp;Bathrooms:&nbsp;</label></td>
                    <td class="addPropertyField"><%= Html.TextBox("Baths") %></td>
                    <td class="addPropertyLabel"><label class="label" for="Fireplaces">#&nbsp;of&nbsp;Fireplaces:&nbsp;</label></td>
                    <td class="addPropertyField"><%= Html.TextBox("Firepl") %></td>
                </tr>
                <tr class="addPropertyRow">
                    <td class="addPropertyLabel"><label class="label" for="FullBaths">#&nbsp;of&nbsp;Full&nbsp;Baths:&nbsp;</label></td>
                    <td class="addPropertyField"><%= Html.TextBox("FBaths") %></td>
                    <td class="addPropertyLabel"><label class="label" for="Rooms">#&nbsp;of&nbsp;Rooms:&nbsp;</label></td>
                    <td class="addPropertyField"><%= Html.TextBox("Rms") %></td>
                </tr>
                <tr class="addPropertyRow">
                    <td class="addPropertyLabel"><label class="label" for="TotalLivingArea">Total Living Area:&nbsp;</label></td>
                    <td class="addPropertyField"><%= Html.TextBox("TLA") %></td>
                    <td class="addPropertyLabel"><label class="label" for="TotalSquareFeet">Total&nbsp;Square&nbsp;Feet:&nbsp;</label></td>    
                    <td class="addPropertyField"><%= Html.TextBox("TSqFt") %></td>                    
                </tr>
                <tr class="addPropertyRow">
                    <td class="addPropertyLabel"><label class="label" for="Garg">Has&nbsp;Garage?:&nbsp;</label></td>
                    <td class="addPropertyField"><%= Html.CheckBox("Garg", false)%></td>
                    <td class="addPropertyLabel"><label class="label" for="GargAttch">Garage&nbsp;Attached?:&nbsp;</label></td>
                    <td class="addPropertyField"><%= Html.CheckBox("GargAttch", false)%></td>
                </tr>
                <tr class="addPropertyRow">
                    <td class="addPropertyLabel"><label class="label" for="Hist">Is&nbsp;Historic:&nbsp;</label></td>
                    <td class="addPropertyField"><%= Html.CheckBox("Hist", false)%></td>
                    <td class="addPropertyLabel"><label class="label" for="MLSNumber">MLS&nbsp;Number:&nbsp;</label></td>
                    <td class="addPropertyField"><%= Html.TextBox("MLSNum") %></td>
                </tr>
                <tr class="addPropertyRow">
                    <td class="addPropertyLabel"><label class="label" for="Bsmnt">Has&nbsp;Basement?:&nbsp;</label></td>
                    <td class="addPropertyField"><%= Html.CheckBox("Bsmnt", "")%></td>
                    <td class="addPropertyLabel"><label class="label" for="NewConst">New&nbsp;Contstruction?:&nbsp;</label></td>
                    <td class="addPropertyField"><%= Html.CheckBox("NewConst", "")%></td>
                </tr>
                <tr class="addPropertyRow">
                    <td class="addPropertyLabel"><label class="label" for="Bedrooms">Bedrooms:&nbsp;</label></td>
                    <td class="addPropertyField"><%= Html.TextBox("BRms")%></td>
                    <td class="addPropertyLabel"><label class="label" for="Frontage">Total&nbsp;Frontage:&nbsp;</label></td>    
                    <td class="addPropertyField"><%= Html.TextBox("Frnt")%></td>                    
                </tr>
                <tr class="addPropertyRow">
                    <td class="addPropertyLabel"><label class="label" for="PriceString">Price:&nbsp;</label></td>
                    <td class="addPropertyField"><%= Html.TextBox("PriceString", String.Format("{0:C}", ViewData.Model.Price))%></td>
                    <td class="addPropertyLabel">&nbsp;</td>
                    <td class="addPropertyField">&nbsp;</td>
                </tr>
                <tr>
                    <td colspan="4"><div id="frmPropertyErr" class="ValidateErrorContainer"></div></td>
                </tr>
            </table>
        </fieldset>
        <div style=" z-index:10; margin-top:30px">
            <input type="submit" value="Search" />
            <button onclick="window.history.back(); return false;">Done</button>
        </div>
    </div>
</form>
</asp:Content>
